﻿#include "OperLoad.h"
#include "OperatorsInterface/OperAbstractSpectra.h"
#include "GUIFrame/MainWindow.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "GUIWidget/BrowserWidget.h"
#include "GUIFrame/CentralWidget.h"

namespace GUIOper
{

    bool OperLoad::execGUI()
    {
        GUI::MainWindow * mainWindow = dynamic_cast<GUI::MainWindow *>(FITKAPP->getGlobalData()->getMainWindow());
        if (!mainWindow || !_emitter)return false;
        //获取动作名称
        QString actionName = _emitter->objectName();
        this->createLoadOper(actionName);
        return true;
    }

    bool OperLoad::execProfession()
    {
        return false;
    }

    void OperLoad::createLoadOper(QString actionName)
    {
        QString name{};
        if (actionName == "actionLoadVpeed")
        {
            name = "OperatorsSpectraVelocity";
        }
        else if (actionName == "actionLoadAngularVelocity")
        {
            name = "OperatorsSpectraAngularVelocity";
        }
        else if (actionName == "actionLoadAcceleratedVelocity")
        {
            name = "OperatorsSpectraAcceleration";
        }
        else if (actionName == "actionLoadForce")
        {
            name = "OperatorsSpectraForce";
        }
        else if (actionName == "actionLoadMoment")
        {
            name = "OperatorsSpectraMoment";
        }
        else if (actionName == "actionLoadSoundPressure")
        {
            name = "OperatorsSpectraPressure";
        }
        else if (actionName == "actionLoadEnergy")
        {
            name = "OperatorsSpectraEnergy";
        }
        else if (actionName == "actionLoadPower")
        {
            name = "OperatorsSpectraPower";
        }
        else
        {
            return;
        }

        auto newOperator = Core::FITKOperatorRepo::getInstance()->getOperatorT<EventOper::OperAbstractSpectra>(name);
        if (newOperator)
            newOperator->createSpectra();
    }
}

